package com.chenfan.mcn.model.dto;

import com.chenfan.mcn.model.base.BaseQueryDTO;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;

import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.List;

/**
 * 红人刊例明细查询DTO
 *
 * @author wulg
 * @date 2021-12-30
 **/
@SuppressWarnings("AlibabaPojoNoDefaultValue")
@Data
@EqualsAndHashCode(callSuper = true)
public class StarRateCardDetailQueryDTO extends BaseQueryDTO {

    private static final long serialVersionUID = 6684368005884939502L;

    /**
     * 刊例ID
     */
    @NotNull(message = "刊例ID不能为空")
    private Long id;

    /**
     * 刊例配置ID
     */
    @NotNull(message = "刊例配置ID不能为空")
    private Long configId;

    /**
     * 红人ID
     */
    private Long starId;

    /**
     * 平台昵称
     */
    private String platNickname;

    /**
     * 经纪人ID
     */
    private Long starAgentId;

    /**
     * 确认状态
     */
    private Integer confirmStatus;

    /**
     * 定制SQL语句
     */
    private String customSql;

    /**
     * 是否统计总数
     */
    private Boolean searchCount = true;

    /**
     * 设置定制SQL
     * @param basicInfoSql
     * @param platformSql
     */
    public void setCustomSql(String basicInfoSql, String platformSql) {
        List<String> list = new ArrayList<>(2);
        if(StringUtils.isNotBlank(basicInfoSql)) {
            list.add(basicInfoSql);
        }
        if(StringUtils.isNotBlank(platformSql)) {
            list.add(platformSql);
        }
        if(CollectionUtils.isNotEmpty(list)) {
            this.customSql = StringUtils.join(list, ",");
        }
    }
}
